<template>
  <div class="inform">
    <HeaderTitle title="评论" />
    <Nmusic title="暂时还没收到评论" />
    <div class="content">
      <div class="more" @click="getMsgComments" v-if="more">加载更多</div>
    </div>
  </div>
</template>

<script>
import Nmusic from "@/components/nMusic";
import HeaderTitle from "./HeaderTitle";
import { msgComments } from "@/api";
import { mapActions, mapGetters } from "vuex";

export default {
  name: "inform",
  components: {
    Nmusic,
    HeaderTitle,
  },
  data() {
    return {
      total: 0,
      more: false,
      before:null,
      comments: [],
    };
  },
  computed: {
    ...mapGetters(["userInfo", "userImgNew"]),
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      this.getMsgComments();
    },
    getMsgComments() {
      msgComments({
        uid: this.userInfo.profile.userId,
        limit: 20,
        before: this.before,
      }).then((data) => {
        this.total = data.total;
        this.more = data.more;
        this.comments = this.comments.concat(data.comments)
        this.before = data.updateTime
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.more{
  text-align: center;
  font-size:12px;
  color:#999;
  cursor: pointer;
}
</style>